package com.graduation.config;

import com.graduation.interceptor.LoginInterceptor;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * 添加@Configuration就是将当前类做配置文件使用,并将bean注入到容器中
 */
@Configuration
public class StoreAppConfiguration implements WebMvcConfigurer {

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        //指定拦截地址
        String path[] = {"/**"};
        //定义放行地址{"/"表示对默认打开地址放行}
        String excludePath [] = {"/css/**","/fonts/**","/images/**","/js/**","/login.do","/userReg.do","/*.ax","/login.do","/loginSys.do"};
        InterceptorRegistration ir = registry.addInterceptor(new LoginInterceptor());
        //设置拦截的路径
        ir.addPathPatterns(path);
        //设置不拦截的路径
        ir.excludePathPatterns(excludePath);
    }
}
